name: Build QA - Config Matrix (Small)



on:
  workflow_dispatch:

  pull_request:
    branches:
      - master
    paths-ignore:
      - '.github/**'
      - '.gitignore'
      - 'ChangeLog'
      - 'COPYING'
      - 'configure.scan'
      - 'packaging/**'
      - 'dev-tools/**'
      - '!dev-tools/libexec/get-release-*.sh'
      - 'doc/**'
      - 'etc/**'
      - 'install/**'
      - 'lib/*/IMPORT.defs'
      - 'lib/*/LICENSE'
      - 'README.md'



jobs:
  build-qa-config-matrix-small:

    name: "Build with flags: '${{matrix.configure_flags}}'"
    runs-on: ubuntu-20.04
    container: ciready/ubuntu:20.04-ci-c



    ### Define the list of configure flag combinations to test out
    #
    strategy:
      matrix:
        configure_flags:
          # Predefined configure flag combinations
          - ""
          #- "--enable-everything"   ### This one already runs in the "OS Matrix" workflow
          - "--enable-everything --disable-thread-safety"
          - "--enable-everything --disable-config-file"
          - "--disable-everything"
          # Random configure flag combinations
          - "random-01"
          - "random-02"
          - "random-03"



    ###
    ### Steps to run
    ###
    steps:



      ### Fetch the code
      #
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0

      # Work around the fix for CVE-2022-24765
      - run: git config --global --add safe.directory $GITHUB_WORKSPACE || true



      ### Build
      #
      - run: ./dev-tools/install-dev-software.sh
      - run: ./bootstrap.sh

      - run: ./configure --enable-option-checking=fatal ${{matrix.configure_flags}}
        if: ${{ ! startsWith(matrix.configure_flags, 'random') }}

      - run: ./configure --enable-option-checking=fatal `./dev-tools/libexec/get-random-configure-flags.sh`
        if: ${{ startsWith(matrix.configure_flags, 'random') }}

      - run: make -j4
      - run: make -j4 check

      - run: cat tests/*/test-suite.log
        if: failure()
